<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<%@ page
	import="com.onlineMIS.common.Common_util,java.util.Date,java.text.SimpleDateFormat"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>禧乐仓连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>

<script>
$(document).ready(function(){
	parent.$.messager.progress('close'); 
		
	$('#headqCustId').combobox('setValue', '');

	var params = $.serializeObject($('#preGenReportForm'));
	
	$('#dataGrid').datagrid({
		url : 'headQReportJSON!getDealiingsAnalysisReportInfo',
		queryParams: params,
		fit : true,
		fitColumns : false,
		pagination : false,
		pageSize : 20,
		pageList : [ 20, 30],
		border : false,
		checkOnSelect : false,
		selectOnCheck : false,
		singleSelect: true,
		showFooter: true,
		rownumbers: true,
		nowrap : false,
		columns : [ [
			{field:'clientId', width:70,title:'客户账号'},
			{field:'clientName', width:190,title:'客户姓名'},
			{field:'ctpDebt', width:80,title:'上期欠款',
				formatter: function (value, row, index){
					return row.ctpDebt.toFixed(2);
				}},
			{field:'ctpPrestore', width:100,title:'上期预存金',
					formatter: function (value, row, index){
						return row.ctpPrestore.toFixed(2);
					}},
			{field:'midtermPayment', width:120,title:'期中回款',
					formatter: function (value, row, index){
						return row.midtermPayment.toFixed(2);
					}},	
			{field:'midtermConsumption', width:120,title:'期中预存金消费',
					formatter: function (value, row, index){
						return row.midtermConsumption.toFixed(2);
					}},		
			{field:'midtermRecharge', width:120,title:'期中预存金充值',
					formatter: function (value, row, index){
						return row.midtermRecharge.toFixed(2);
					}},
			{field:'midtermSale', width:120,title:'期中销售',
					formatter: function (value, row, index){
						return row.midtermSale.toFixed(2);
					}},
			{field:'midtermReturn', width:120,title:'期中退货',
					formatter: function (value, row, index){
						return row.midtermReturn.toFixed(2);
					}},
			{field:'endDebt', width:120,title:'期末欠款',
					formatter: function (value, row, index){
						return row.endDebt.toFixed(2);
					}},	
			{field:'endPrestore', width:100,title:'期末预存金',
					formatter: function (value, row, index){
						return row.endPrestore.toFixed(2);
					}},
			{field:'nowDebt', width:120,title:'当前欠款',
					formatter: function (value, row, index){
						return row.nowDebt.toFixed(2);
					}},
			{field:'nowPrestore', width:120,title:'当前预存金',
					formatter: function (value, row, index){
						return row.nowPrestore.toFixed(2);
					}}
		]],
		toolbar : '#toolbar',
	});
});


	//查询报表
	function generateReport() {
			var params = $.serializeObject($('#preGenReportForm'));
			$('#dataGrid').datagrid('load', params);		
	}

	//下载单据
	function downloadReport() {
		document.preGenReportForm.action = "headqReportJSP!downloadDealingsReportInfo";
		document.preGenReportForm.submit();
	}
	
</script>
</head>
<body>
	<div class="easyui-layout" data-options="fit : true,border : false">
		<div data-options="region:'north',border:false" style="height: 95px;">
			<s:form id="preGenReportForm" name="preGenReportForm" action="" theme="simple" method="POST">
								
				<table width="98%" align="center" class="OuterTable">
					<tr>
						<td>
							<table width="100%" border="0">
								<tr>
									<td height="50" colspan="6">
										<div class="errorAndmes">
											<s:actionerror cssStyle="color:red" />
											<s:actionmessage cssStyle="color:blue" />
										</div>
										<table width="100%" border="0">
											<tr class="PBAOuterTableTitale">
												<td height="35" colspan="6">查询往来分析报表信息：</td>
											</tr>
											<tr class="InnerTableContent">

												<td width="3%" align="center"><strong>日期:</strong></td>
												<td width="20%"><s:textfield id="startDate"
														name="formBean.startDate" cssClass="easyui-datebox"
														data-options="width:120,editable:false" /> &nbsp; 至&nbsp;
													<s:textfield id="endDate" name="formBean.endDate"
														cssClass="easyui-datebox"
														data-options="width:120,editable:false" /></td>
												<td width="5%" align="center"><strong>选择客户:</strong></td>
												<td width="15%"><s:select size="1"
														cssClass="easyui-combobox" style="width:85%"
														data-options="prompt:'请选择客户',onChange:function(a,b){selectCust();}"
														headerKey="" headerValue="" id="headqCustId"
														list="uiBean.custs" listKey="id" name="formBean.cust.id"
														listValue="name" /></td>

												<td width="5%" align="center"><strong>客户标签：</strong></td>
												<td >
														<input class="easyui-tagbox" name="formBean.tagGroups" id="tags"  style="width:45%" data-options="
											                url: 'headQCustMgmtJSONAction!listCusTags',
											                method: 'get',
											                groupField:'groupName',
											                value: '',
											                valueField: 'id',
											                textField: 'tagName',
											                limitToList: true,
											                hasDownArrow: true,
											                prompt: '请选择客户标签',
											                tagStyler: function(value){
										                    if (value >0 && value <=3){
										                        return 'background:#ffd7d7;color:#c65353';
										                    } else if (value >= 4 && value <17){
										                        return 'background:#76EEC6;color:#c65353';
										                    }else if (value >= 17 && value <19){
										                        return 'background:#7EC0EE;color:#c65353';
										                    }else if (value >= 19 ){
										                        return 'background:#EEB422;color:#c65353';
										                    }
										                }
											                ">
														</td>
												
											</tr>

										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>

			</s:form>
		</div>
		<div data-options="region:'center',border:false">
			<table id="dataGrid" border="0">
			</table>
			<div id="toolbar" style="display: none;">
				<a onclick="generateReport();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="iconCls:'icon-search',plain:true">查询报表</a>
				 <a
					onclick="downloadReport();" href="javascript:void(0);"
					class="easyui-linkbutton"
					data-options="plain:true,iconCls:'icon-print'">下载报表</a>	
			</div>
		</div>
	</div>
</body>
</html>